﻿using UnityEditor;
using UnityEngine;
using System.IO;

namespace Anderson.Editor
{
    public class BuildAssetBundles
    {
        public const string AssetBundlePath = "AssetBundle";

        [MenuItem("Anderson/AssetBundles/Build for x86_64")]
        static void CreateAssetBundle()
        {
            string path = Application.dataPath + "/" + AssetBundlePath + "/x86_64";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
        }

        [MenuItem("Anderson/AssetBundles/Build for x64")]
        static void CreateAssetBundle_x64()
        {
            string path = Application.dataPath + "/" + AssetBundlePath + "/x64"; ;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
        }

        [MenuItem("Anderson/AssetBundles/Build for OSX")]
        static void CreateAssetBundle_MacOS()
        {
            string path = Application.dataPath + "/" + AssetBundlePath + "/OSX"; ;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX);
        }
    }
}